'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app
  router.get('/', controller.home.index)
  router.get('/user', controller.user.getUsers)
  router.get('/user/:id', controller.user.getUser)
  // topic
  router.resources('topic', '/topic', controller.topic)
  // topicType
  router.resources('topic', '/topicType', controller.topicType)
  // oauth2
  app.all('/access/token', app.oAuth2Server.token()); // 获取token
  app.all('/access/authorize', app.oAuth2Server.authorize()); // 获取授权码
  app.all('/access/authenticate', app.oAuth2Server.authenticate(), controller.user.getUsers); // 验证请求
};
